package com.chuyu.jzwboa.adapter.notice;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.chuyu.jzwboa.R;

import java.util.List;

/**
 * Created by Administrator on 2017/12/15.
 */

public class NoticePopupWindowAdapter extends BaseAdapter {
	private Context mContext;
	private List<String> mList;
	private int currFocusId = 0;

	public NoticePopupWindowAdapter(Context context, List<String> list) {
		this.mContext = context;
		this.mList = list;
	}

	@Override
	public int getCount() {
		return mList == null ? 0 : mList.size();
	}

	@Override
	public Object getItem(int i) {
		return null;
	}

	@Override
	public long getItemId(int i) {
		return 0;
	}

	@Override
	public View getView(int i, View view, ViewGroup viewGroup) {
		ViewHolder viewHolder;
		if (view == null) {
			viewHolder = new ViewHolder();
			view = LayoutInflater.from(mContext).inflate(R.layout.item_popupwindow_notice, null);
			viewHolder.tv_all = (TextView) view.findViewById(R.id.tv_all);
			view.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) view.getTag();
		}
		viewHolder.tv_all.setText(mList.get(i));
		if (i == currFocusId) { // 执行判断
			// 设置背景
			viewHolder.tv_all.setBackgroundResource(R.drawable.textview_blue_selector);
			viewHolder.tv_all.setTextColor(Color.WHITE);
		}
		return view;
	}

	class ViewHolder {
		TextView tv_all;
	}
}
